using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using Atom.Data.BusinessObjects;
using Atom.Data.Base;

namespace Atom.Data.ManagerObjects
{
    public partial interface IHLeavehosRecordManager : IManagerBase<Atom.Data.BusinessObjects.HLeavehosRecord, string>
    {
		// Get Methods
		HLeavehosRecord GetById(System.String inhosid, System.Int32 currentinhosmark);
    }

    partial class HLeavehosRecordManager : ManagerBase<Atom.Data.BusinessObjects.HLeavehosRecord, string>, IHLeavehosRecordManager
    {
		#region Constructors
		
		public HLeavehosRecordManager() : base()
        {
        }
        public HLeavehosRecordManager(INHibernateSession session) : base(session)
        {
        }
		
		#endregion
		
        #region Get Methods

		public override HLeavehosRecord GetById(string id)
		{
			string[] keys = id.Split('^');
			
			if(keys.Length != 2)
				throw new Exception("Invalid Id for HLeavehosRecordManager.GetById");
			
			return GetById(keys[0], System.Int32.Parse(keys[1]));
		}
		public HLeavehosRecord GetById(System.String inhosid, System.Int32 currentinhosmark)
		{
			ICriteria criteria = Session.GetISession().CreateCriteria(typeof(HLeavehosRecord));
			
			criteria.Add(NHibernate.Criterion.Expression.Eq("Inhosid", inhosid));
			criteria.Add(NHibernate.Criterion.Expression.Eq("Currentinhosmark", currentinhosmark));
			
			HLeavehosRecord result = (HLeavehosRecord)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
		}
		
		
		#endregion
    }
}